<?php 
include 'data/data.php';
$playerid=$_GET['player'];
?>
<html><head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>用户注册 - <?php echo $rowx[name]; ?></title>
    <style>
        body {
            font-size: 12px;
            background: white;
            max-width: 600px;
            margin: 0 auto;
        }
        img{
            display:block;
        }
        .dv-1 {

            /*height: 220px;*/
            /*background: url("/images/register2/bg.png");*/
            /*background-repeat: no-repeat;*/
            /*background-size: 100%;*/
        }

        .dv-2 {
            /*height: 150px;*/
            /*background: url("/images/register2/bg2.png");*/
            /*background-repeat: no-repeat;*/
            /*background-size: 100%;*/
            /*padding-bottom: 9px;*/
        }

        .dv-3 {

            height: 5px;
            background: rgb(244, 244, 244);
        }

        .dv-4 {
            padding-top: 10px;
            width: 100%;
            height: 190px;
            text-align: center;
            background: white;
        }
        .dv-4-register {
            margin-left: 33%;
            text-align: center;
        }
        .dv-5 {
            /*height: 45px;*/
            width: 100%;
            text-align: center;
            background: white;
        }

        .dv-5-btn {
            margin-left: 5%;
            width: 90%;
        }
        .account{
            background: url('/images/register2/account.png') left center no-repeat;
            background-size: auto 16px;
        }
        .account,.password {
            width: 84%;
            margin-left: 5%;
            height: 32px;
            margin-top: 0.9rem;
            border-bottom: 1px solid #f0f0f0;
            padding-left: 1.4rem;
            font-size: 0.7rem;
            color: #bababa;
        }
        input{
            width: 100%;
            color: #bababa;
            height: 32px;
            padding: 0;
            margin-left: 16px;
            border: none;
            background: none;
            outline: none;
        }
        .password {
            background: url('/images/register2/password.png') left center no-repeat;
            background-size: auto 16px;
        }
        .dv-6{
            padding-top: 5px;
            padding-left: 5%;
            background: white;
            height: 50px;
        }
        .body{
            background: url('/images/register2/bg01.png');
            background-repeat: no-repeat;
            background-size: 100%;
        }
    </style>
</head>
<body class="body">
<div class="dv-1">
    <img src="/images/register2/bg.png" alt="" width="100%" height="auto">
</div>
<div class="dv-2">
    <img src="/images/register2/bg2.png" alt="" width="100%" height="auto">
</div>
<div class="dv-3"></div>
<div class="dv-4">
    <img class="dv-4-register" src="/images/register2/register.png" width="33%">
    <div class="account">
        <input type="text" class="icon-account" placeholder="账号" autocomplete="off" id="username">
    </div>
    <div class="password">
        <input type="password" class="icon-password" placeholder="密码" autocomplete="off" id="password">
    </div>
    <div class="password">
        <input type="password" class="icon-password" placeholder="确认密码" autocomplete="off" id="repassword">
    </div>

</div>
<div class="dv-5 login_btn">
    <img src="/images/register2/button.png" class="dv-5-btn">
</div>
<div class="dv-6">阅读并同意《注册协议》</div>

<script src="/public/scripts/jquery-1.11.1.min.js"></script>
<script src="/public/scripts/jquery.mobile.min.js"></script>
<script>
    $('.login_btn').on('tap', function(){
        if( ! checkUsername() ) return false;
        if( ! checkPassword() ) return false;
        var u = $.trim($("#username").val());
        var p = $.trim($("#password").val());
        var rp = $.trim($("#repassword").val());
        if(p!=rp){
            alert('两次密码不一致!');
            return false;
        }
        $.ajax({
            type: 'POST',
            url: '/user/ajaxlogin.html',
            data: 'username='+u+'&password='+p+'&player=<?php echo $playerid; ?>'+'&type=reg',
            dataType: 'json',
	        success: function(data){
	            console.log('data',data);
			 if(data.info!='success'){
               if(data.fwd!=''){
               loading = false;
               alert(data.info);location.href=data.fwd;
               }else{
               loading = false;
               alert(data.info);
               }
             }else{
               if(data.fwd!=''){
               alert('注册成功');location.href='/user/user.html';
               }else{
               location.href='/user/user.html';
               }
             }
	        },
	        error: function(){
	        	loading = false;
	        	alert('网络连接失败！');
	        }
        });
    });
    function checkUsername(){
        var v = $.trim($("#username").val());
        var reg_phone = /^(?:13[0-9]|14[57]|15[0-9]|17[0678]|18[0-9])\d{8}$/;
        var reg_email = /^[\w\-\.]+@[\w\-]+(\.\w+)+$/;
        var reg_name = /^[a-zA-Z0-9_-]{4,16}$/;
        if(reg_phone.test(v)){
            return true;
        } else if(reg_email.test(v) || reg_name.test(v)){
            $('#phone_code').hide();
            return true;
        } else{
            $('#phone_code').hide();
            alert("请输入有效的手机号码或者邮箱地址！");
            $("#username").focus();
            return false;
        }
    }
    function checkPassword(){
        var v = $.trim($('#password').val());
        if( v.length < 6 ) {
            alert('为了你的账号安全，请输入6位以上的密码！');
            $("#password").focus();
            return false;
        }
        return true;
    }
    function imgdragstart(){return false;}
    for(i in document.images)document.images[i].ondragstart=imgdragstart;
</script>
</body></html>